<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Candidate_requirement_claims_controller
 *
 * @author wilson
 */
class CandidateRequirementClaimsController extends AppController {

    //put your code here
    var $name = "CandidateRequirementClaims";

    function edit($id) {
        if (empty($this->data)) {
            $textoRequerimiento = $this->CandidateRequirementClaim->query(
                    "SELECT Requirements.texto FROM candidate_requirement_claims CandidateRequirementClaim
                     LEFT JOIN candidate_requirements CandidateRequirement ON  CandidateRequirementClaim.candidate_requirement_id = CandidateRequirement.id
                     LEFT JOIN requirements Requirements ON CandidateRequirement.requirement_id = Requirements.id
                     WHERE CandidateRequirementClaim.id = $id"
            );
            $this->set('textoRequerimiento', $textoRequerimiento);

            $textoRequirementFault = $this->CandidateRequirementClaim->query(
                    "SELECT RequirementFault.nombre FROM candidate_requirement_claims CandidateRequirementClaim
                     LEFT JOIN candidate_requirements CandidateRequirement ON  CandidateRequirementClaim.candidate_requirement_id = CandidateRequirement.id
                     LEFT JOIN candidate_requirements_requirement_faults CandidateRequirementsRequirementFault ON
                     CandidateRequirementsRequirementFault.candidate_requirement_id = CandidateRequirement.id
                     LEFT JOIN requirement_faults RequirementFault ON RequirementFault.id = CandidateRequirementsRequirementFault.requirement_fault_id
                     WHERE CandidateRequirementClaim.id = $id"
            );
            $this->set('textoRequirementFault', $textoRequirementFault);

            $this->data = $this->CandidateRequirementClaim->find('first', array('conditions' => array('CandidateRequirementClaim.id' => $id),'fields'=>array('CandidateRequirementClaim.id','CandidateRequirementClaim.concepto','CandidateRequirementClaim.calificacion','CandidateRequirementClaim.claim_id')));
        
            
        } else {
            if ($this->CandidateRequirementClaim->saveAll($this->data)) {
                $this->Session->setFlash('Reclamacion editada con éxito');
                $this->redirect(array('controller' => 'Claims', 'action' => 'total_index', $this->data['CandidateRequirementClaim']['claim_id']));
            }
        }
    }
     
    
    function recalification($id) {
        if (empty($this->data)) {
            $textoRequerimiento = $this->CandidateRequirementClaim->query(
                    "SELECT Requirements.texto FROM candidate_requirement_claims CandidateRequirementClaim
                     LEFT JOIN candidate_requirements CandidateRequirement ON  CandidateRequirementClaim.candidate_requirement_id = CandidateRequirement.id
                     LEFT JOIN requirements Requirements ON CandidateRequirement.requirement_id = Requirements.id
                     WHERE CandidateRequirementClaim.id = $id"
            );
            $this->set('textoRequerimiento', $textoRequerimiento);

            $textoRequirementFault = $this->CandidateRequirementClaim->query(
                    "SELECT RequirementFault.nombre FROM candidate_requirement_claims CandidateRequirementClaim
                     LEFT JOIN candidate_requirements CandidateRequirement ON  CandidateRequirementClaim.candidate_requirement_id = CandidateRequirement.id
                     LEFT JOIN candidate_requirements_requirement_faults CandidateRequirementsRequirementFault ON
                     CandidateRequirementsRequirementFault.candidate_requirement_id = CandidateRequirement.id
                     LEFT JOIN requirement_faults RequirementFault ON RequirementFault.id = CandidateRequirementsRequirementFault.requirement_fault_id
                     WHERE CandidateRequirementClaim.id = $id"
            );
            $this->set('textoRequirementFault', $textoRequirementFault);

            $this->data = $this->CandidateRequirementClaim->find('first', array('conditions' => array('CandidateRequirementClaim.id' => $id),'fields'=>array('CandidateRequirementClaim.id','CandidateRequirementClaim.concepto_territorial','CandidateRequirementClaim.calificacion_territorial','CandidateRequirementClaim.claim_id')));
        
            
        } else {
            if ($this->CandidateRequirementClaim->saveAll($this->data)) {
                $this->Session->setFlash('Reclamacion editada con éxito');
                $this->redirect(array('controller' => 'Claims', 'action' => 'recalification_index', $this->data['CandidateRequirementClaim']['claim_id']));
            }
        }
    }
    
}

?>
